package com.sbtr.business.publishtask.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sbtr.business.publishtask.entity.PublishTaskData;
import com.sbtr.common.PageDto;
import com.sbtr.common.Response;
import com.sbtr.open.publishtask.dto.*;

import java.util.List;

/**
 * <p>
 * 数据类部署任务表 服务类
 * </p>
 */
public interface IPublishTaskDataService extends IService<PublishTaskData> {

    /**
     * 模型发布<br>
     * 接口会对模型进行完整的校验(是否重复发布、状态等)<br>
     * 会对推理服务器的资源进行策略过滤，匹配最优一个进行调用<br>
     * 如果校验不能发布/服务器资源不足等问题，方法会抛出exception，返回RestResponse<br>
     * 方法没有对同一个模型高并发的幂等性处理，调用者请知悉！！
     *
     * @param req - 请求参数封装
     * @return 调用结果
     * @author qiujun
     * @date 2019-10-29
     */
    Response<Boolean> publishModel(PublishTaskDataReqDto req);

    PublishTaskDataDto findById(Long id);

    PageDto<PublishTaskDataDto> search(String taskName, Long currPage, Long pageSize, Long projectId);


    boolean deleteById(Long id);

    boolean stopTask(Long id);

//	@RequestMapping(value = "/{id}/predict-data", method = RequestMethod.POST)
//	  List<PredictDataResultDto> predictData(@PathVariable("id") Long id, @RequestBody PredictDataReqDto reqDto);

    List<PredictDataResultDto> predictData(Long id, PredictNewDto reqDto);

//	@RequestMapping(value = "/{id}/predict-data-multi-create", method = RequestMethod.POST)
//	  PublishPredictTaskDto predictDataMultiCreate(@PathVariable("id") Long id,
//			@RequestBody PredictDataMultiReqDto req);

    PublishPredictTaskDto predictDataMultiCreate(Long id,
                                                 PredictDataMultiNewDto req);


    PublishTaskDataDto findByProjectId(Long projectId);


//	@RequestMapping(value = "/{id}/predict-data-multi", method = RequestMethod.POST)
//	  void predictDataMulti(@PathVariable("id") Long id, @RequestBody PublishPredictTaskDto dto);


    JSONObject predictDataMulti(Long id, PredictDataMultiNewDto dto) throws InterruptedException;

    PublishTaskDataDto findByModel(Long modelId);

    JSONArray getPredictJSON(Long id);

}
